import { createStore, Store } from 'vuex';
import createPersistedState from 'vuex-persistedstate';
import createState, { Theme } from '@x-tech/fe-starter-pc-shadow/src/store/modules/puma';
import app from '@/store/modules/app';
import userGroup from '@/store/modules/userGroup';
import plan from '@/store/modules/plan';
import { State } from 'vue';

const theme = (window.XCConfig.VITE_THEME || 'red') as Theme;
const plugins = [
    createPersistedState({
        storage: window.localStorage,
        paths: ['app.config', 'app.common', 'puma', 'userGroup'],
    }),
];

export default createStore({
    plugins,
    modules: {
        puma: createState({ theme }),
        app,
        userGroup,
        plan,
    },
}) as unknown as Store<State>;
